<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>好友留言板</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Helvetica Neue', Arial, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
            color: #1565c0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            max-width: 1200px;
            padding: 25px;
            background: rgba(255, 255, 255, 0.9);
            box-shadow: 0 5px 20px rgba(33, 150, 243, 0.15);
            border-radius: 15px;
            overflow: hidden;
        }
        
        h1 {
            text-align: center;
            color: #0d47a1;
            margin-bottom: 20px;
            font-weight: 600;
            font-size: 28px;
        }
        
        .input-section {
            width: 100%;
            max-width: 800px;
            margin-bottom: 30px;
            background: #fff;
            padding: 25px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(33, 150, 243, 0.1);
            transition: transform 0.3s ease;
        }
        
        .input-section:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(33, 150, 243, 0.2);
        }
        
        .board-selector {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .board-selector label {
            font-weight: 500;
            color: #1976d2;
        }
        
        .board-selector select {
            padding: 10px 15px;
            border: 1px solid #90caf9;
            border-radius: 8px;
            background-color: #e3f2fd;
            color: #1565c0;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            outline: none;
        }
        
        .board-selector select:hover {
            background-color: #bbdefb;
            border-color: #64b5f6;
        }
        
        .input-section textarea {
            width: 100%;
            max-width: 100%;
            margin-bottom: 15px;
            padding: 15px;
            border: 1px solid #90caf9;
            border-radius: 8px;
            font-size: 16px;
            color: #1565c0;
            resize: none;
            transition: border-color 0.3s ease;
            background: #e1f5fe;
            outline: none;
        }
        
        .input-section textarea:focus {
            border-color: #42a5f5;
            box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
        }
        
        .input-section textarea::placeholder {
            color: #64b5f6;
        }
        
        .input-section button {
            padding: 12px 25px;
            background: linear-gradient(to right, #42a5f5, #1976d2);
            color: #fff;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 500;
            transition: all 0.3s ease;
            box-shadow: 0 3px 5px rgba(33, 150, 243, 0.3);
        }
        
        .input-section button:hover {
            background: linear-gradient(to right, #3b8fda, #1565c0);
            transform: translateY(-2px);
            box-shadow: 0 5px 8px rgba(33, 150, 243, 0.4);
        }
        
        .boards {
            display: flex;
            justify-content: space-around;
            width: 100%;
            max-width: 1200px;
            gap: 20px;
        }
        
        .board {
            flex: 1;
            background: #fff;
            border: 1px solid #90caf9;
            border-radius: 12px;
            padding: 20px;
            box-shadow: 0 4px 12px rgba(33, 150, 243, 0.1);
            transition: transform 0.3s ease;
        }
        
        .board:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 16px rgba(33, 150, 243, 0.15);
        }
        
        .board h2 {
            text-align: center;
            color: #1976d2;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #bbdefb;
            font-weight: 600;
        }
        
        .board .messages {
            max-height: 350px;
            overflow-y: auto;
            padding: 15px;
            background-color: #e1f5fe;
            border: 1px solid #bbdefb;
            border-radius: 10px;
        }
        
        .board .message {
            padding: 15px;
            margin-bottom: 15px;
            background-color: #fff;
            border-left: 4px solid #42a5f5;
            border-radius: 8px;
            font-size: 14px;
            color: #1565c0;
            transition: background-color 0.3s ease;
            box-shadow: 0 2px 5px rgba(33, 150, 243, 0.1);
        }
        
        .board .message:hover {
            background-color: #e3f2fd;
        }
        
        .message-content {
            margin-bottom: 8px;
            line-height: 1.5;
        }
        
        .message-time {
            font-size: 12px;
            color: #64b5f6;
            margin-bottom: 10px;
        }
        
        .board .message button {
            padding: 6px 12px;
            background-color: #f44336;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 12px;
            transition: background-color 0.3s ease;
        }
        
        .board .message button:hover {
            background-color: #d32f2f;
        }
        
        .board .messages::-webkit-scrollbar {
            width: 8px;
        }
        
        .board .messages::-webkit-scrollbar-thumb {
            background-color: #90caf9;
            border-radius: 4px;
        }
        
        .board .messages::-webkit-scrollbar-track {
            background-color: #bbdefb;
            border-radius: 4px;
        }
        
        .empty-message {
            text-align: center;
            color: #64b5f6;
            font-style: italic;
            padding: 20px;
        }
        
        @media (max-width: 900px) {
            .boards {
                flex-direction: column;
            }
            
            .board {
                margin-bottom: 20px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <h1>留言板</h1>
    
    <div class="input-section">
        <div class="board-selector">
            <label for="boardSelect">选择留言板：</label>
            <select id="boardSelect">
                <option value="board1">留言板一</option>
                <option value="board2">留言板二</option>
                <option value="board3">留言板三</option>
            </select>
        </div>
        <form id="messageForm">
            <textarea id="messageInput" placeholder="请输入您的留言..." rows="4"></textarea>
            <button type="submit">提交留言</button>
        </form>
    </div>
    
    <div class="boards">
        <div class="board" id="board1">
            <h2>留言板一</h2>
            <div class="messages" id="messages1">
                <div class="empty-message">暂无留言，快来发表吧～</div>
            </div>
        </div>
        <div class="board" id="board2">
            <h2>留言板二</h2>
            <div class="messages" id="messages2">
                <div class="empty-message">暂无留言，快来发表吧～</div>
            </div>
        </div>
        <div class="board" id="board3">
            <h2>留言板三</h2>
            <div class="messages" id="messages3">
                <div class="empty-message">暂无留言，快来发表吧～</div>
            </div>
        </div>
    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', () => {
        const messageForm = document.getElementById('messageForm');
        const messageInput = document.getElementById('messageInput');
        const boardSelect = document.getElementById('boardSelect');
        const boards = ['board1', 'board2', 'board3'];
        
        // 初始化留言数据
        let allBoards = JSON.parse(localStorage.getItem('allBoards')) || {
            board1: [],
            board2: [],
            board3: []
        };

        // 显示所有留言板的留言
        function displayMessages() {
            boards.forEach(board => {
                const messagesDiv = document.getElementById(`messages${board.slice(-1)}`);
                const messages = allBoards[board];
                
                messagesDiv.innerHTML = '';
                
                if (messages.length === 0) {
                    messagesDiv.innerHTML = '<div class="empty-message">暂无留言，快来发表吧～</div>';
                    return;
                }
                
                messages.forEach((messageData, index) => {
                    const messageElement = document.createElement('div');
                    messageElement.classList.add('message');
                    messageElement.innerHTML = `
                        <div class="message-content">${messageData.text}</div>
                        <div class="message-time">${messageData.time}</div>
                        <button class="delete-button" data-board="${board}" data-index="${index}">删除</button>
                    `;
                    messagesDiv.appendChild(messageElement);
                });
            });
        }

        // 初始化时显示所有留言板的留言
        displayMessages();

        messageForm.addEventListener('submit', (e) => {
            e.preventDefault();
            const message = messageInput.value.trim();
            if (message) {
                const currentBoard = boardSelect.value;
                const now = new Date();
                const timeString = now.toLocaleString('zh-CN', {
                    year: 'numeric',
                    month: '2-digit',
                    day: '2-digit',
                    hour: '2-digit',
                    minute: '2-digit'
                });
                
                allBoards[currentBoard].push({
                    text: message,
                    time: timeString
                });
                
                localStorage.setItem('allBoards', JSON.stringify(allBoards));
                displayMessages();
                messageInput.value = '';
                
                // 添加提交动画效果
                const button = messageForm.querySelector('button');
                button.textContent = '已提交 ✓';
                button.style.background = 'linear-gradient(to right, #2196f3, #1565c0)';
                
                setTimeout(() => {
                    button.textContent = '提交留言';
                    button.style.background = 'linear-gradient(to right, #42a5f5, #1976d2)';
                }, 1500);
            }
        });

        // 监听删除按钮的点击事件
        document.addEventListener('click', (e) => {
            if (e.target.classList.contains('delete-button')) {
                const board = e.target.getAttribute('data-board');
                const index = e.target.getAttribute('data-index');
                allBoards[board].splice(index, 1);
                localStorage.setItem('allBoards', JSON.stringify(allBoards));
                displayMessages();
            }
        });
    });
</script>
</body>
</html>